//
//  UserRequest.swift
//  物料商行
//
//  Created by HaoDong Hong on 2017/8/13.
//  Copyright © 2017年 HaoDong Hong. All rights reserved.
//

import Alamofire
import SwiftyJSON

enum UserRequest: RequestProtocol {
    case sendMessage(phone: String)
    case login(phone: String, password: String)
    case registe(phone: String, password: String)
    case forget(phone: String, newPass: String, validateCode: String)
    case logout(phone: String)
    case getIcon
    case upload(email: String?, name: String?)
    
    
    var path: String {
        switch self {
        case .sendMessage(_):
            return "app/message"
        case .login(_, _):
            return "app/login"
        case .registe(_, _):
            return "app/reg"
        case .forget(_, _, _):
            return "app/forget"
        case .logout(_):
            return "app/logout"
        case .getIcon:
            return "app/ShowImage"
        case .upload(_, _):
            return "app/Setting"
        }
        
    }
    var bodyParams: Parameters {
        switch self {
        case .sendMessage(let phone):
            return ["userPhone": phone]
        case .login(let phone, let password):
            return ["userPhone": phone, "userPass": password]
        case .registe(let phone, let password):
            return ["userPhone": phone, "userPass": password]
        case .forget(let phone, let newPass, let validateCode):
            return ["userPhone": phone, "userPass": newPass, "ValidateCode": validateCode]
        case .logout(let phone):
            return ["userPhone": phone]
        case .getIcon:
            return ["session_id": User.sessionID!]
        case .upload(let email, let name):
            return ["session_id": User.sessionID!, "userEmail": email ?? "yourEmail@xxx.com", "userName": name ?? "yourName"]
        }
    }
    var fullURL: URL {
        let str = self.host + self.path
        return URL(string: str)!
    }
}
